-
Notifications
You must be signed in to change notification settings - Fork 63
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Refactor the abstract class CreateConnectedElementI #1047
base: cpacs_creator_dev_merge
Are you sure you want to change the base?
Refactor the abstract class CreateConnectedElementI #1047
Conversation
…riant In the current implementation of the CPACS Creator, the Wing and Fuselage class are inherited from an abstract class. We want to avoid this behaviour and fix the code style by removing this class and adding a new std::variant type instead. In the actual code, it is then decided whether the current object is of type Wing or Fuselage and the respective member function is called.
Codecov ReportAll modified and coverable lines are covered by tests ✅
Additional details and impacted files@@ Coverage Diff @@
## cpacs_creator_dev_merge #1047 +/- ##
========================================================
Coverage 71.40% 71.40%
========================================================
Files 312 312
Lines 28978 28976 -2
========================================================
Hits 20691 20691
+ Misses 8287 8285 -2
Flags with carried forward coverage won't be shown. Click here to find out more.
|
…ng the right type
|
||
private: | ||
Ui::ModificatorSectionsWidget* ui; | ||
tigl::CreateConnectedElementI* createConnectedElementI; | ||
Ui::ElementModificatorInterface* createConnectedElement; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I believe with the current changes, we should store by value here. The ElementModificatorInterface
goes out of scope at the end of the function where it is created and the pointer can be dangling. In addition, the ElementModificatorInterface
already stores the fuselage or wing by reference.
@@ -42,11 +77,11 @@ public slots: | |||
explicit ModificatorSectionsWidget(QWidget* parent = nullptr); | |||
~ModificatorSectionsWidget(); | |||
|
|||
void setCreateConnectedElementI(tigl::CreateConnectedElementI& elementI); | |||
void setCreateConnectedElement(Ui::ElementModificatorInterface& element); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Can't the argument be const
?
void setCreateConnectedElement(Ui::ElementModificatorInterface& element); | |
void setCreateConnectedElement(Ui::ElementModificatorInterface const& element); |
Description
In the current implementation of the CPACS Creator, the Wing and Fuselage class are inherited from an abstract class (cf. #1042). We want to avoid this behaviour and fix the code style by removing this class and adding a new
std::variant
type instead. In the actual code, it is then decided whether the current object is of type Wing or Fuselage and the respective member function is called.Later on, the variant type can be extended by any other class (such as Duct, Pylon, Tank, ...), if the CPACS Creator should be able to add CPACS elements/sections within the according object.
The general procedure (and whether this is the best way) of course still can be discussed. Nonetheless, @joergbrech and I had a disscussion about it and agreed that using
std::variant
seems to be a good way to solve this code style issue.Fix #1042